class Solution {
    public boolean isPerfectSquare(int num) {
        int min = 0, max = 46340;
        return binSearch(min, max, num);
    }

    public boolean binSearch(int min, int max, int num) {
        int mid = (min + max) / 2;
        if (min * min == num || mid * mid == num || max * max == num) {
            return true;
        }
        if (min >= max) return false;

        if (num < mid * mid) {
            return binSearch(min, mid, num);
        } else {
            return binSearch(mid + 1, max, num);
        }
    }
}
